package com.chandon.juc.threadPool;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 自定义线程工厂
 *
 * @author Dong
 */

public class NamedThreadFactory implements ThreadFactory {

	private String threadFactoryName;
	private String namePrefix = "线程";
	AtomicInteger threadNum = new AtomicInteger(1);
	public NamedThreadFactory(String threadFactoryName) {
		this.threadFactoryName = threadFactoryName;
	}

	@Override
	public Thread newThread(Runnable r) {

		Thread thread = new Thread(r, namePrefix + threadNum);
		threadNum.incrementAndGet();

		return thread;
	}


}
